<?php 
ob_start();
if(!isset($_SESSION)){
	session_start();
	}
	if(!isset($_SESSION['userName'])){
		header("location:login.php");
	}else{
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sannhao</title>
    <link rel="Stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
    <div class="wrapper">
    <?php include("top.php");?>
    
        <div class="body">
            <div style="margin-bottom: 10px">
                <div style="float: left" class="text-3">
                    Xin chào <?php echo $_SESSION["userName"];?>
                </div>
                <div style="float: right">
                    <a href="#">Tài khoản</a> | <a href="#">Danh sách của tôi</a> | <a href="#">Thông tin
                        cá nhân</a>
                </div>
                <div class="vide">
                </div>
            </div>
            <div style="margin-bottom: 10px">
                <div style="float: left">
                    <h2>
                        Đăng thông tin nhà tại Sànnhàở.com
                    </h2>
                </div>
                <div style="float: right">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <img alt="" border="0" src="images/step1.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step2.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step3.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step4_orange.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step5.gif" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="vide">
                </div>
            </div>
            <table cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td class="title-2">
                        Hình ảnh
                    (Đẳng làm script phần thêm hình)</td>
                </tr>
                <tr>
                    <td style="padding: 10px 0 10px 0">
                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                            <tr>
                                <td style="vertical-align: top; width: 200px">
                                    <img alt="" border="1px" src="upload/095.jpg" />                                </td>
                                    <?php 
if(isset($_POST['upload'])){
	if(isset($_POST['flag']) == 1){
		session_register("flag");
		$_SESSION["flag"] = 1;
		require "upload.php";
	
	$config["folder"]	= "images"; // Đường dẫn thư mục chứa hình
	$config["name"]		= "images"; //Tên Input file
	$config["type"]		= "jpg|png|gif"; //Định dạng cho Upload
	$config["size"]		= "100000"; //Kích thước file tối đa được upload

	$a = new Libraries_upload($config);
	
	$a->do_upload_multi();
	if($a->checkerror())
		echo "Upload thanh cong";
	else
	{
		echo $a->showerror();
		echo "Upload that bai";

	}
	}else{
		session_register("flag");
				$_SESSION["flag"] = 2;
		if(isset($_POST['name_image'])){
			$name_image = $_POST['name_image'];
			session_register("name_image");
			$_SESSION["name_image"] = $name_image;
		}
	}
/*
else{
$name_image = "095.jpg";// ảnh default
session_register("name_image");
$_SESSION["name_image"] = $name_image;

session_register("flag");
$_SESSION["flag"] = 1;

}
*/
}else{
?>
                              <td style="vertical-align: top">
                               <form id="fupload" name="fupload" action="step4.php" method="post">                               
                                    <table cellpadding="5" cellspacing="0" align="center">
                                        <tr>
                                            <td class="text-1">
                                                Hình ảnh                                            </td>
                                            <td>
                                                <input id="flag" name="flag" type="radio" value="1" />
                                                Tải ảnh từ máy tính                                            </td>
                                          <td>
                                          
                                            <input type="file" name="images[]" size="25" /><br />
 											<input type="file" name="images[]" size="25" /><br />
											<input type="file" name="images[]" size="25" /><br />
											<input type="file" name="images[]" size="25" /><br />
<label>&nbsp;</label></td>
                                        </tr>
                                        <tr>
                                            <td class="text-1" style="vertical-align: bottom" rowspan="2">
                                                Tên hình                                            </td>
                                            <td rowspan="2" style="vertical-align: top">
                                                <input id="flag" name="flag" type="radio" value="2" />
                                                Tải ảnh từ web                                            </td>
                                            <td>
                                                <input id="name_image" name="name_image" type="text" style="width: 195px" class="textbox" />                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input id="Text1" type="text" style="width: 195px" class="textbox" />                                            </td>
                                        </tr>
                                    <tr>
                                          <td colspan="3" align="center" style="font-style: italic"><input type="submit" name="ok" value="Upload" /></td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" align="center" style="font-style: italic">
                                                * Vui lòng nhập hình chỉ tối đa 2 MB                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1" style="vertical-align: top" colspan="3" align="center">
                                                <input id="Button1" type="button" value="Thêm hình" class="button" />                                            </td>
                                        </tr>
                                    </table>
                                    
                                    <table cellpadding="4" cellspacing="2" style="width: 100%">
                                        <tr>
                                            <td align="center" style="background-color: #6699cc; color: White; width: 40%; font-weight: bold;
                                                font-size: 14px">
                                                Hình ảnh
                                            </td>
                                            <td align="center" style="background-color: #6699cc; color: White; width: 40%; font-weight: bold;
                                                font-size: 14px">
                                                Tên hình
                                            </td>
                                            <td align="center" style="background-color: #6699cc; color: White; width: 20%; font-weight: bold;
                                                font-size: 14px">
                                                Xóa
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                [Hình ảnh]
                                            </td>
                                            <td>
                                                abc.jpg
                                            </td>
                                            <td>
                                                [Delete]
                                            </td>
                                        </tr>
                                    </table>
                                    </form>
                                </td>
                                <?php }?>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <div>
                <div style="float: left">
                    <a href="step3.htm">
                        <img alt="" border="" src="images/back_button.jpg" /></a>
                </div>
                <div style="float: right">
                    <a href="finish.php">
                        <img alt="" border="" src="images/next_button.jpg" /></a>
                </div>
                <div class="vide">
                </div>
            </div>
        </div>
        
    </div>
    <?php include("footer.php");?>
</body>
</html>
<?php }
ob_end_flush();
?>